//
//  HYLShopView.m
//  纯代码封装
//
//  Created by hyl on 16/5/1.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "HYLShopView.h"
#import "HYLShop.h"
@interface HYLShopView ()

@property (nonatomic,strong) UIImageView *iconView;
@property (nonatomic,strong) UILabel *lableView;
@end
@implementation HYLShopView
/** 重写layoutSubviews */
-(void)layoutSubviews{
//   防止意外的问题
    [super layoutSubviews];
    CGFloat w=self.frame.size.width;
    CGFloat h=self.frame.size.height;
    self.iconView.frame=CGRectMake(0, 0, w, w);
    self.lableView.frame=CGRectMake(0, w, w, h-w);
}
/** 重写setter方法 */
-(void)setShop:(HYLShop *)shop{
    _shop=shop;
    self.lableView.text=shop.name;
    self.iconView.image=[UIImage imageNamed:shop.icon];
}

-(UIImageView *)iconView{
    if (_iconView==nil) {
        UIImageView *iconView=[[UIImageView alloc]init];
        [self addSubview:iconView];
        _iconView=iconView;
    }
    return _iconView;
}
-(UILabel *)lableView{
    if (_lableView==nil) {
        UILabel *lableView=[[UILabel alloc]init];
        lableView.font=[UIFont systemFontOfSize:11];
        lableView.textAlignment=NSTextAlignmentCenter;
        [self addSubview:lableView];
        _lableView=lableView;
    }
    return _lableView;
}
@end
